<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>子元素相对父元素居中</title>
    <style>
        html, *{
            margin: 0;
            padding: 0;


        }

        body{
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
        }
        .son{

            width: 300px;
            height: 300px;
            background-color: #9DB783;
            flex: 0 1 auto;
        }

    </style>



</head>
<body>

    <div class="son">
        
    </div>

</body>
</html>